package com.starlight.ts_clouddev.controller;

import com.starlight.ts_clouddev.infrastructure.entity.CloudInstancePrice;
import com.starlight.ts_clouddev.service.CloudInstancePriceService;
import com.starlight.ts_clouddev.util.CloudResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author yfy2001
 * @date 2023/5/18 15:13
 */
@RestController
@RequestMapping("/instancePrice")
public class CloudInstancePriceController {

    @Resource
    private CloudInstancePriceService cloudInstancePriceService;

    @PostMapping ("/create")
    public CloudResponse<Boolean> create(CloudInstancePrice cloudInstancePrice){
        return CloudResponse.success(cloudInstancePriceService.save(cloudInstancePrice));
    }

    @PostMapping("/update")
    public CloudResponse<Boolean> update(CloudInstancePrice cloudInstancePrice){
        return CloudResponse.success(cloudInstancePriceService.updateById(cloudInstancePrice));
    }

    @GetMapping("/read")
    public CloudResponse<List<CloudInstancePrice>> read(){
        return CloudResponse.success(cloudInstancePriceService.list());
    }

    @PostMapping("/delete")
    public CloudResponse<Boolean> delete(CloudInstancePrice cloudInstancePrice){
        return CloudResponse.success(cloudInstancePriceService.removeById(cloudInstancePrice));
    }
}
